package Server;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.ServerSocket;
import java.net.Socket;

public class Server {


	public static void main(String[] args) {

		try{
			ServerSocket ss = new ServerSocket(6969);
			while(true)
			{

				Socket client = ss.accept();

				BufferedReader br = new BufferedReader(new InputStreamReader(client.getInputStream()));
				BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(client.getOutputStream()));
				String line = br.readLine();
				System.out.println(line);
				bw.write(line);

				while(!line.equals("end"))
				{
					bw.write(line);
					System.out.println(line);
					
				}
				bw.flush();
				bw.close();
			}


		}

		catch(IOException e){

			System.out.println("error:" + e.getMessage());
		}

	}
}
